package com.cjm.one.controller.customer;

import com.cjm.one.common.result.Result;
import com.cjm.one.model.custom.dto.BindEmailDto;
import com.cjm.one.model.custom.dto.PasswordSetDto;
import com.cjm.one.model.custom.dto.PayPasswordSetDto;
import com.cjm.one.model.custom.entity.CustomerInfo;
import com.cjm.one.model.payment.BalanceDto;
import com.cjm.one.service.CustomerInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.Min;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@Slf4j
@Tag(name = "用户信息", description = "用户信息")
@RequestMapping("/api/customer/info")
public class CustomerInfoController {

    @Resource
    private CustomerInfoService customerInfoService;

    @PutMapping("/update")
    @Operation(summary = "更新用户信息")
    public Result<CustomerInfo> getCustomerInfo(@RequestBody CustomerInfo customerInfo){
        return customerInfoService.updateCustomerInfo(customerInfo);
    }


    @PostMapping("/passwordSet")
    @Operation(summary = "修改密码")
    public Result<Boolean> passwordSet(@RequestBody PasswordSetDto passwordSetDto) {

        return customerInfoService.passwordSet(passwordSetDto);
    }

    @PostMapping("/payPasswordSet")
    @Operation(summary = "修改支付密码")
    public Result<Boolean> payPasswordSet(@RequestBody PayPasswordSetDto passwordSetDto) {
        return customerInfoService.payPasswordSet(passwordSetDto);
    }

    @PostMapping("/bindEmailSet")
    @Operation(summary = "绑定邮箱")
    public Result<String> bindEmailSet(@RequestBody BindEmailDto passwordSetDto) {
        return customerInfoService.bindEmailSet(passwordSetDto);
    }

    @PostMapping("/addBalance/{value}")
    @Operation(summary = "充值余额虚假接口，测试用")
    public Result<Boolean> addBalance(@PathVariable("value")  BigDecimal value){
        return customerInfoService.addBalance(value);
    }

    @PostMapping("/pay")
    @Operation(summary = "支付虚假接口，测试用")
    public Result<Long> pay(@RequestBody BalanceDto balanceDto){
        return customerInfoService.pay(balanceDto);
    }
}
